#include<iostream>
#include<cctype>
using namespace std;

const int N = 25;
char arr[N];

int main()
{
	int n = 0;
	cin >> n;
	int i = 0;
	while(n--)
	{
		cin >> arr;
		if(islower(arr[0]))
			arr[0] = toupper(arr[0]);
		
		int j = 1;
		while(arr[j] != '\0')
		{
			if(isupper(arr[j]))
				arr[j] = tolower(arr[j]);
			j++;
		}
		cout << arr << endl;
	}
	
	return 0;
}
